﻿@model UserRegisterModel
@{
    ViewData["Title"] = "新增用户信息";
}

<div class="content-page-header">
    <h2>新增用户信息</h2>
    <button class="btn btn-outline" onclick="backToPrevPage()">
        <i class="fas fa-arrow-left"></i> 返回列表
    </button>
</div>

<div class="content-card">
    <form method="post" asp-controller="user" asp-action="add" class="row g-3" enctype="multipart/form-data">
        <div class="col-md-6">
            <label class="form-label" for="username">用户名(<span class="text-danger">*</span>)</label>
            <input type="text" id="username" name="username" class="form-control" placeholder="请输入登录用户名" asp-for="UserName" />
            <span asp-validation-for="UserName" class="text-danger small"></span>
        </div>
        <div class="col-md-6">
            <label class="form-label" for="name">用户昵称(<span class="text-danger">*</span>)</label>
            <input type="text" id="name" name="name" class="form-control" placeholder="请输入用户昵称" asp-for="Name" />
            <span asp-validation-for="Name" class="text-danger small"></span>
        </div>

        <div class="col-md-6">
            <label class="form-label" for="password">密码(<span class="text-danger">*</span>)</label>
            <input type="password" id="password" name="password" class="form-control" placeholder="请输入登录密码" asp-for="Password" />
            <span asp-validation-for="Password" class="text-danger small"></span>
        </div>
        <div class="col-md-6">
            <label class="form-label" for="confirmpassword">确认密码(<span class="text-danger">*</span>)</label>
            <input type="password" id="confirmpassword" name="confirmpassword" class="form-control" placeholder="请再次输入登录密码" asp-for="ConfirmPassword" />
            <span asp-validation-for="ConfirmPassword" class="text-danger small"></span>
        </div>

        <div class="col-md-6">
            <label class="form-label" for="avatar">头像</label>
            <input type="file" id="avatar" name="avatar" class="form-control" asp-for="Avatar" />
        </div>
        <div class="col-md-6">
            <label class="form-label" for="phone">手机号</label>
            <input type="tel" id="phone" name="phone" class="form-control" asp-for="Phone" />
            <span asp-validation-for="Phone" class="text-danger small"></span>
        </div>
        <div class="col-md-6">
            <label class="form-label" for="truename">真实姓名</label>
            <input type="tel" id="truename" name="truename" class="form-control" asp-for="TrueName" />
        </div>
        <div class="col-md-6">
            <label class="form-label">性别</label>
            <div>
                <div class="form-check form-check-inline">
                    @if (Model == null || Model.Gender == SysGender.Unknown)
                    {
                        <input class="form-check-input" type="radio" id="gender1" name="gender" value="2" checked />
                    }
                    else
                    {
                        <input class="form-check-input" type="radio" id="gender1" name="gender" value="2" />
                    }
                    <label class="form-check-label" for="gender1">未知</label>
                </div>
                <div class="form-check form-check-inline">
                    @if (Model != null && Model.Gender == SysGender.Male)
                    {
                        <input class="form-check-input" type="radio" id="gender2" name="gender" value="1" checked />
                    }
                    else
                    {
                        <input class="form-check-input" type="radio" id="gender2" name="gender" value="1" />
                    }
                    <label class="form-check-label" for="gender2">男</label>
                </div>
                <div class="form-check form-check-inline">
                    @if (Model != null && Model.Gender == SysGender.Female)
                    {
                        <input class="form-check-input" type="radio" id="gender3" name="gender" value="0" checked />
                    }
                    else
                    {
                        <input class="form-check-input" type="radio" id="gender3" name="gender" value="0" />
                    }
                    <label class="form-check-label" for="gender3">女</label>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <label class="form-label" for="truename">出生日期</label>
            <input type="date" id="birthday" name="birthday" class="form-control" placeholder="可不填写" asp-for="Birthday" />
        </div>
        <div class="col-md-6">
            <label class="form-label" for="truename">身份证号码</label>
            <input type="text" id="idcard" name="idcard" class="form-control" placeholder="可不填写" asp-for="IdCard" />
        </div>

        <div class="col-12">
            <label class="form-label">居住地址</label>
            <textarea class="form-control" id="address" name="address" rows="3" placeholder="可不填写" asp-for="Address"></textarea>
        </div>

        <div class="col-12">
            <label class="form-label">备注</label>
            <textarea class="form-control" id="remarks" name="remarks" rows="3" placeholder="可不填写" asp-for="Remarks"></textarea>
        </div>

        <!--暂不完善角色权限功能-->
        @* <div class="col-md-6">
            <label class="form-label">角色</label>
            <select class="form-select">
                <option selected>超级管理员</option>
                <option>内容编辑</option>
                <option>财务人员</option>
                <option>普通用户</option>
            </select>
        </div> *@

        <div class="col-12 mt-4">
            <button type="submit" class="btn btn-primary me-2 px-4">保存</button>
            <a asp-controller="user" asp-action="index" class="btn btn-outline-secondary">取消</a>
            <input type="hidden" id="hidMsg" value="@Model?.ResultMessage" />
        </div>
    </form>
</div>

@section Scripts {
    <script type="text/javascript" lang="zh-cn" language="javascript">
        window.onload = function(){
            //处理后端返回提示信息
            var resultMsg = document.querySelector("#hidMsg").value;
            if(resultMsg && resultMsg.length > 0){
                showMessage("新增用户", resultMsg);
            }
        }
    </script>
}